﻿#region imports

using System;
using System.Collections.Generic;
using System.Linq;
using Codeplex.ODataTFS.Model.Entities;
using Codeplex.ODataTFS.Model.Serialization;

#endregion

namespace Codeplex.ODataTFS.Model.Repositories
{
	public class ProjectRepository
	{
		private readonly TFSProjectProxy _proxy;

		public ProjectRepository(TFSProjectProxy proxy)
		{
			_proxy = proxy;
		}

		public Project GetOne(string name)
		{
			return _proxy.GetProjectsByProjectCollection().SingleOrDefault(t => t.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
		}

		public IEnumerable<Project> GetAll()
		{
			return _proxy.GetProjectsByProjectCollection();
		}
	}
}
